import Vue from 'vue'
// import { $get, $post, $upload, $export } from './axios'
// import download from './utils/download'
// import { message } from 'ant-design-vue'
// import TinymceEditor from './components/form/TinymceEditor'
// import UploadImage from './components/form/UploadImage'
// import UploadFile from './components/form/UploadFile'
// import FastRangePicker from './components/form/FastRangePicker'
// import SearchTable from './components/form/SearchTable'
// import TableImg from './components/form/TableImg'
// import Permission from './components/common/Permission'


const path = require('path')
const files = require.context('./components', false, /\.vue$/) // 找以vue结尾的文件 第二个参数是否检测 子目录
console.log("files",files)

// const modules = {}
// files.keys().forEach(key => {
//   const name = path.basename(key, '.vue')
//   modules[name] = files(key).default || files(key)
// })
//
// console.log("modules",modules)

// 全局批量注册组件
/*files.keys().forEach(key => {
  const reqCom = files(key)  // 组件实例
  const reqComName = reqCom.name || key.replace(/\.\/(.*)\.vue/, '$1')  // 截取路径作为组件名
  Vue.component(reqComName, reqCom.default || reqCom)  // 组件挂载
})*/

import A from './components/A'
import WSelect from './components/WSelect'
import WSimpleForm from './components/simple-form/src/index'
import WForm from './components/Wform/src/index'
import WDialog from './components/dialog/src/index'
import WDatePicker from './components/date-picker/src/index'

// import { getImgView } from './utils'

import * as filters from './filters/index'
import * as directives from './directive/golbalDirective/index'

function install (Vue) {
  /*全局过滤器安装*/
  Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
  })
  /*全局指令安装*/
  Object.keys(directives).forEach(key => {
    Vue.directive(key, directives[key])
  })

  /*全局方法的安装*/
  // Vue.$getImgView = Vue.prototype.$getImgView = getImgView
  // Vue.$get = Vue.prototype.$get = $get
  // Vue.$post = Vue.prototype.$post = $post
  // Vue.$upload = Vue.prototype.$upload = $upload
  // Vue.$export = Vue.prototype.$export = $export
  // Vue.$download = Vue.prototype.$download = download

  /*全局组件的安装*/
  // Vue.component(GModal.name, GModal)
  // 富文本组件
  // Vue.component(TinymceEditor.name, TinymceEditor)
  // 上传文件组件，默认单图上传，使用limit(数量限制)属性控制上传多图
  // Vue.component(UploadImage.name, UploadImage)
  // 上传文件组件，默认单文件上传，使用limit(数量限制)属性控制上传多个文件
  // Vue.component(UploadFile.name, UploadFile)
  // 带今，昨天，近七日，近30日的时间选择器
  // Vue.component(FastRangePicker.name, FastRangePicker)
  // 带搜索的表格模板
  // Vue.component(SearchTable.name, SearchTable)
  // 表格项是图片
  // Vue.component(TableImg.name, TableImg)
  // 权限控制组件
  // Vue.component(Permission.name, Permission)
  Vue.component(A.name, A)
  Vue.component(WSelect.name, WSelect)
  Vue.component(WSimpleForm.name, WSimpleForm)
  Vue.component(WForm.name, WForm)
  Vue.component(WDialog.name, WDialog)
  Vue.component(WDatePicker.name, WDatePicker)


 /* message.config({
    duration: 2,
    maxCount: 2
  })*/
}
Vue.use(install)
// 需要在main.js 里面导进去 import "./common"..

// 1. 如果Vue.use() 中的参数是一个function函数，那么函数的参数是Vue对象。
// 2. 如果Vue.use() 中的参数是一个Object对象，那么这个对象必须提供一个install方法，install方法的参数就是Vue。
